﻿using ARPaintServer.Model.ObjectDetection;
using ARPaintServer.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ARPaintServer.Controllers
{
	[Route("api/[controller]")]
	[ApiController]
	public class ObjectDetectionController : ControllerBase
	{
		private readonly IObjectDetectionService _objectDetectionService;
        private readonly ILogger<ObjectDetectionController> _logger;
		// 文字识别服务只能在Windows环境下运行
		//private readonly IOCRService _oCRService;


		// public ObjectDetectionController(IObjectDetectionService objectDetectionService,ILogger<ObjectDetectionController> logger,IOCRService oCRService)
		public ObjectDetectionController(IObjectDetectionService objectDetectionService,ILogger<ObjectDetectionController> logger)
		{
			_objectDetectionService = objectDetectionService;
            //_oCRService = oCRService;
            _logger = logger;
		}

		[HttpPost("Object")]
		public async Task<ActionResult<ItemResult>> GetObject(ImageInfo imageInfo)
		{
			_logger.LogInformation("接受到一个物体识别任务");
			var result=await _objectDetectionService.GetObjects(imageInfo);
			return Ok(result);
		}


		//[HttpPost("Text")]
		//public async Task<ActionResult<ItemResult>> GetText(ImageInfo imageInfo)
		//{
		//	_logger.LogInformation("接受到一个文字识别任务");
		//	var result = await _oCRService.GetTextFromBase64(imageInfo.ImageBase64, imageInfo.ImageName);
		//	return Ok(result);
		//}

	}
}
